<?php
/*
+-----------------------------------------------------------------------------+
| $Id: *.php 2009-08-18 08:41:22Z Bleakwind $
| Copyright (c) 2003-2010 Bleakwind (www.weaverdream.com)
| http://www.weaverdream.com/
+-----------------------------------------------------------------------------+
*/

if (!defined( 'ENTRY_INDEX')){
    echo "<h1>Forbidden</h1><p>You don't have permission to access on this server.</p>";
    exit;
}

function question_select($id, $value)
{
    global $LANGUAGE,$LANGLIST,$SETTING, $member_info;
    $ajax_response = new xajaxResponse();
    if ( $value == "custom"){
        $question_custom_value = $member_info['question_type'] == "1" ? "" : $member_info['question'];
        $ajax_response->assign($id, "innerHTML", '<br />自定义:<input type="text" id="question_custom" name="question_custom" size="30" style="width:250px;" maxlength="30" value="'.$question_custom_value.'" class="input">');
    }else{
        $ajax_response->assign($id, "innerHTML", '');
    }
    return $ajax_response;
}
$bwajax->register(XAJAX_FUNCTION, "question_select");

// Member add and amend ajax
function submit_form($type, $value, $submit)
{
    global $LANGUAGE,$LANGLIST,$SETTING,$CONFIGURE,$MEMBER,$ADMIN,$db,$sys,$c,$setting_cover,$setting_attach;
    $ajax_response = new xajaxResponse();
    $error = false;
    //$ajax_response->alert(print_r($value, true)); $ajax_response->assign($submit,"disabled",false); return $ajax_response;

    if ($type == "amend") {
        $submit_value   = "编辑";
    } else {
        $submit_value   = "添加";
    }

    if( empty($value['username']) ) {
        $error = true;
        if(empty($anchor)) { $anchor = "username"; }
        $ajax_response->assign("username_return", "innerHTML", "<span class=\"prompt_failed\">必须填写会员名称<!-- username error --></span>");
    } else {
        $ajax_response->assign("username_return", "innerHTML", "");
    }

    if ( !empty($value['email']) ) {
        if ( !preg_match("/^[a-z0-9-_\.]+@([a-z0-9][a-z0-9-]*\.)+[a-z]{2,4}$/i",$value['email']) ) {
            $error = true;
            if(empty($anchor)) { $anchor = "email"; }
            $ajax_response->assign("email_return", "innerHTML", "<span class=\"prompt_failed\">E-mail格式错误<!-- email error --></span>");
        } else {
            $ajax_response->assign("email_return", "innerHTML", "");
        }
    }

    if( !preg_match("/^[1-9][0-9]{0,10}$/",$value['question']) && $value['question'] != "custom" ){
        $error = true;
        if(empty($anchor)) { $anchor = "question"; }
        $ajax_response->assign("question_return", "innerHTML", "<span class=\"prompt_failed\">密码提示问题必需设定<!-- question error --></span>");
    } else {
        if ($value['question'] == "custom") {
            if ( mb_strwidth($value['question_custom'],"UTF-8") < 6 ||
                mb_strwidth($value['question_custom'],"UTF-8") > 30 ) {
                $error = true;
                if(empty($anchor)) { $anchor = "question"; }
                $ajax_response->assign("question_return", "innerHTML", "<span class=\"prompt_failed\">自定义密码提示问题时必须填写密码提示问题,6-30字节,汉字,英文,数字或下划线<!-- question error --></span>");
            } else {
                $question_type = "2";
                $question = $value['question_custom'];
                $ajax_response->assign("question_return", "innerHTML", "");
            }
        } else {
            $question_type = "1";
            $question = $value['question'];
            $ajax_response->assign("question_return", "innerHTML", "");
        }
    }

    if ( mb_strwidth($value['answer'],"UTF-8") < 6 ||
        mb_strwidth($value['answer'],"UTF-8") > 30 ) {
        $error = true;
        if(empty($anchor)) { $anchor = "answer"; }
        $ajax_response->assign("answer_return", "innerHTML", "<span class=\"prompt_failed\">密码提示答案不符合要求,合法密码提示答案应该在6-30字节之间,可以使用汉字,英文,数字和下划线,请重新输入</span>");
    } else {
        $ajax_response->assign("answer_return", "innerHTML", "");
    }

    if( empty($value['mg_type']) ) {
        $error = true;
        if(empty($anchor)) { $anchor = "mg_type"; }
        $ajax_response->assign("mg_type_return", "innerHTML", "<span class=\"prompt_failed\">必须选择会员群组<!-- mg_type error --></span>");
    } else {
        $ajax_response->assign("mg_type_return", "innerHTML", "");
    }

    if( !preg_match("/^[0-9-]+$/",$value['mg_type_expired']) ) {
        $error = true;
        if(empty($anchor)) { $anchor = "mg_type_expired"; }
        $ajax_response->assign("mg_type_expired_return", "innerHTML", "<span class=\"prompt_failed\">时间限制格式错误,且不能为空<!-- mg_type_expired error --></span>");
    } else {
        $ajax_response->assign("mg_type_expired_return", "innerHTML", "");
    }

    if( !preg_match("/^[0-9]+$/",$value['point']) ) {
        $error = true;
        if(empty($anchor)) { $anchor = "point"; }
        $ajax_response->assign("point_return", "innerHTML", "<span class=\"prompt_failed\">必须设定会员积分,积分只能为数字<!-- point error --></span>");
    } else {
        $ajax_response->assign("point_return", "innerHTML", "");
    }

    if( !preg_match("/^[123]+$/",$value['if_active']) ) {
        $error = true;
        if(empty($anchor)) { $anchor = "if_active"; }
        $ajax_response->assign("if_active_return", "innerHTML", "<span class=\"prompt_failed\">必须选择激活状态<!-- if_active error --></span>");
    } else {
        $ajax_response->assign("if_active_return", "innerHTML", "");
    }

    if( !preg_match("/^[123]+$/",$value['if_enable']) ) {
        $error = true;
        if(empty($anchor)) { $anchor = "if_enable"; }
        $ajax_response->assign("if_enable_return", "innerHTML", "<span class=\"prompt_failed\">必须选择会员状态<!-- if_enable error --></span>");
    } else {
        $ajax_response->assign("if_enable_return", "innerHTML", "");
    }

    if( !preg_match("/^[123]+$/",$value['if_email']) ) {
        $error = true;
        if(empty($anchor)) { $anchor = "if_email"; }
        $ajax_response->assign("if_email_return", "innerHTML", "<span class=\"prompt_failed\">必须选择是否订阅邮件<!-- if_email error --></span>");
    } else {
        $ajax_response->assign("if_email_return", "innerHTML", "");
    }

    if($error){
        $ajax_response->assign($submit,"value",$submit_value);
        $ajax_response->assign($submit,"disabled",false);
        $ajax_response->redirect("#".$anchor);
    }else{

        if ($type == "amend") {

            if (!preg_match("/^[1-9][0-9]{0,10}$/",$sys->get['mid'])){
                $ajax_response->alert("用户ID错误!");
                $ajax_response->assign($submit,"value",$submit_value);
                $ajax_response->assign($submit,"disabled",false);
            } else {

                $result_member = func::db_select(DB_TABLE_MEMBER, "*", "id=".$sys->get['mid']);
                $result_member = $result_member[0];
                if (!preg_match("/^[1-9][0-9]{0,10}$/",$result_member['id'])) {
                    $ajax_response->alert("此会员不存在!");
                    $ajax_response->assign($submit,"value",$submit_value);
                    $ajax_response->assign($submit,"disabled",false);
                } else {

                    $total_record['username']   = func::db_count_record(DB_TABLE_MEMBER, "username='".addslashes($value['username'])."' AND id!=".(int)$sys->get['mid']);
                    $total_record['email']      = func::db_count_record(DB_TABLE_MEMBER, "email='".addslashes($value['email'])."' AND id!=".(int)$sys->get['mid']);
                    if ($total_record > 0) {
                        $ajax_response->alert("此会员名称已经存在,请重新填写");
                        $ajax_response->assign($submit,"value",$submit_value);
                        $ajax_response->assign($submit,"disabled",false);
                    } else {

                        if ( !empty($value['password']) ){
                            $sql_password = "password='".func::str_encrypt($value['password'])."',";
                        } else {
                            $sql_password = "";
                        }

                        if ( $value['if_active'] == "1" && $result_member['if_active'] != "1"){
                            $sql_active = "active_id='".(int)$ADMIN['mid']."',ip_active='".func::return_ip()."',time_active='".$sys->nowtime."',";
                        } else {
                            $sql_active = "";
                        }

                        if ( $value['if_active'] != "1"){
                            if ($value['if_enable'] == "1") {
                                $ajax_response->alert("激活状态为关闭的时候,会员状态必须也为关闭!");
                                $ajax_response->assign($submit,"value",$submit_value);
                                $ajax_response->assign($submit,"disabled",false);
                            }
                        }

                        if ($value['mg_type_expired'] != 0) {
                            $value['mg_type_expired'] = strtotime($value['mg_type_expired']);
                        }
                        $sql = "UPDATE ".DB_TABLE_MEMBER." SET
                                    username        = '".addslashes($value['username'])."',
                                    email           = '".addslashes($value['email'])."',
                                    ".$sql_password."
                                    question_type   =".(int)$question_type.",
                                    question        ='".addslashes($question)."',
                                    answer          = '".addslashes($value['answer'])."',
                                    mg_type         = '".addslashes($value['mg_type'])."',
                                    mg_type_expired = '".addslashes((int)$value['mg_type_expired'])."',
                                    point           = '".addslashes((int)$value['point'])."',
                                    ".$sql_active."
                                    if_active       = '".addslashes($value['if_active'])."',
                                    if_enable       = '".addslashes($value['if_enable'])."',
                                    if_email        = '".addslashes($value['if_email'])."'
                                WHERE id=".$sys->get['mid']."";
                        $result = $db->Execute($sql);
                        if (!$result) {
                            $ajax_response->alert($db->ErrorMsg());
                            $ajax_response->assign($submit,"value",$submit_value);
                            $ajax_response->assign($submit,"disabled",false);
                        }else{
                            $ajax_response->redirect($CONFIGURE['common']['control_admin']."?act=member&pag=".$sys->get['pag']);
                        }
                    }
                }
            }

        } else {

            $total_record = func::db_count_record(DB_TABLE_MEMBER, "username='".addslashes($value['username'])."'");
            if ($total_record > 0) {
                $ajax_response->alert("此会员名称已经存在,请重新填写!");
                $ajax_response->assign($submit,"value",$submit_value);
                $ajax_response->assign($submit,"disabled",false);
            } elseif (empty($value['password'])) {
                $ajax_response->alert("必须填写会员密码!");
                $ajax_response->assign($submit,"value",$submit_value);
                $ajax_response->assign($submit,"disabled",false);
            } else {

                if ( $value['if_active'] == "1"){
                    $sql_active = "active_id='".(int)$ADMIN['mid']."',ip_active='".func::return_ip()."',time_active='".$sys->nowtime."',";
                } else {
                    $sql_active = "";
                }

                if ( $value['if_active'] != "1"){
                    if ($value['if_enable'] == "1") {
                        $ajax_response->alert("激活状态为关闭的时候,会员状态必须也为关闭!");
                        $ajax_response->assign($submit,"value",$submit_value);
                        $ajax_response->assign($submit,"disabled",false);
                    }
                }

                if ($value['mg_type_expired'] != 0) {
                    $value['mg_type_expired'] = strtotime($value['mg_type_expired']);
                }
                $sql = "INSERT INTO ".DB_TABLE_MEMBER." SET
                            username        = '".addslashes($value['username'])."',
                            email           = '".addslashes($value['email'])."',
                            password        ='".func::str_encrypt($value['password'])."',
                            question_type   =".(int)$question_type.",
                            question        ='".addslashes($question)."',
                            answer          = '".addslashes($value['answer'])."',
                            mg_type         = '".addslashes($value['mg_type'])."',
                            mg_type_expired = '".addslashes((int)$value['mg_type_expired'])."',
                            point           = '".addslashes((int)$value['point'])."',
                            ".$sql_active."
                            if_active       = '".addslashes($value['if_active'])."',
                            if_enable       = '".addslashes($value['if_enable'])."',
                            if_email        = '".addslashes($value['if_email'])."',
                            ip_created      = '".func::return_ip()."',
                            time_created    = '".$sys->nowtime."',
                            cumulant_silver = '0',
                            cumulant_offer  = '0',
                            cumulant_online = '0'";
                $result = &$db->Execute($sql);
                $last_record = $db->Insert_ID();
                if (!$result) {
                    $ajax_response->alert($db->ErrorMsg().$sql);
                    $ajax_response->assign($submit,"value",$submit_value);
                    $ajax_response->assign($submit,"disabled",false);
                }else{
                    $ajax_response->redirect($CONFIGURE['common']['control_admin']."?act=member&pag=".$sys->get['pag']);
                }
            }
        }
    }


    return $ajax_response;
}
$bwajax->register(XAJAX_FUNCTION, "submit_form");
//////

if($sys->get['ope'] == "add"){

    $sql = "SELECT mg_id, mg_type, mg_point_begin, mg_point_end, mg_name
            FROM ".DB_TABLE_MEMBER_GROUP."
            WHERE mg_type!='".$CONFIG['default_group_guest']."'
            GROUP BY mg_type
            ORDER BY mg_rank,mg_id";
    $result_member_group = &$db->Execute($sql);
    if (!$result_member_group) {
        echo $db->ErrorMsg();
    } else {
        while(!$result_member_group->EOF) {
            $member_group_list[] = array(
                "mg_id"             => $result_member_group->fields['mg_id'],
                "mg_type"           => $result_member_group->fields['mg_type'],
                "mg_point_begin"    => $result_member_group->fields['mg_point_begin'],
                "mg_point_end"      => $result_member_group->fields['mg_point_end'],
                "mg_name"           => $result_member_group->fields['mg_name'],
            );
            $result_member_group->MoveNext();
        }
    }

    $array_select  = array("question");
    $select_option = $sys->return_select($array_select);

    $t->assign(array(
        "member_group_list" => $member_group_list,
        "select_option"     => $select_option,
    ));

}elseif($sys->get['ope'] == "amend"){

    if (!preg_match("/^[0-9]+$/",$sys->get['mid'])){
        $sys->prompt("failed","非法操作!<!-- mid error -->");
    }else{

        $sql = "SELECT m.*, mg.*, ag.*
                FROM ".DB_TABLE_MEMBER." m
                LEFT JOIN ".DB_TABLE_MEMBER_GROUP." mg ON mg.mg_type=m.mg_type
                    AND (mg.mg_point_begin<=m.point || mg.mg_point_begin IS NULL)
                    AND (mg.mg_point_end>=m.point || mg.mg_point_end IS NULL)
                LEFT JOIN ".DB_TABLE_ADMIN_GROUP." ag ON ag.ag_id=mg.mg_ag_id
                WHERE m.id=".$sys->get['mid']."
                GROUP BY m.id";
        $result = &$db->Execute($sql);
        if (!$result) {
            echo $db->ErrorMsg();
        } else {
            if (!$result->EOF) {

                $member_info = array(
                    'id'                            => $result->fields['id'],
                    'username'                      => $result->fields['username'],
                    'email'                         => $result->fields['email'],
                    'card'                          => $result->fields['card'],
                    'password'                      => $result->fields['password'],
                    'question_type'                 => $result->fields['question_type'],
                    'question'                      => $result->fields['question'],
                    'answer'                        => $result->fields['answer'],
                    'mg_type'                       => $result->fields['mg_type'],
                    'mg_type_expired'               => $result->fields['mg_type_expired'],
                    'silver'                        => $result->fields['silver'],
                    'point'                         => $result->fields['point'],
                    'bonus'                         => $result->fields['bonus'],
                    'pile1'                         => $result->fields['pile1'],
                    'pile2'                         => $result->fields['pile2'],
                    'pile3'                         => $result->fields['pile3'],
                    'pile4'                         => $result->fields['pile4'],
                    'pile5'                         => $result->fields['pile5'],
                    'pile6'                         => $result->fields['pile6'],
                    'active_id'                     => $result->fields['active_id'],
                    'if_active'                     => $result->fields['if_active'],
                    'if_enable'                     => $result->fields['if_enable'],
                    'if_email'                      => $result->fields['if_email'],
                    'ip_active'                     => $result->fields['ip_active'],
                    'ip_created'                    => $result->fields['ip_created'],
                    'ip_change'                     => $result->fields['ip_change'],
                    'ip_lastvisit'                  => $result->fields['ip_lastvisit'],
                    'time_active'                   => $result->fields['time_active'],
                    'time_created'                  => $result->fields['time_created'],
                    'time_change'                   => $result->fields['time_change'],
                    'time_lastvisit'                => $result->fields['time_lastvisit'],
                    'cumulant_silver'               => $result->fields['cumulant_silver'],
                    'cumulant_offer'                => $result->fields['cumulant_offer'],
                    'cumulant_online'               => $result->fields['cumulant_online'],

                    'mg_id'                         => $result->fields['mg_id'],
                    'mg_type'                       => $result->fields['mg_type'],
                    'mg_point_begin'                => $result->fields['mg_point_begin'],
                    'mg_point_end'                  => $result->fields['mg_point_end'],
                    'mg_ag_id'                      => $result->fields['mg_ag_id'],
                    'mg_name'                       => $result->fields['mg_name'],
                    'mg_brief'                      => $result->fields['mg_brief'],
                    'mg_icon'                       => $result->fields['mg_icon'],
                    'mg_privilege'                  => unserialize($result->fields['mg_privilege']),
                    'mg_fileallow'                  => unserialize($result->fields['mg_fileallow']),
                    'mg_if_enable'                  => $result->fields['mg_if_enable'],
                    'mg_rank'                       => $result->fields['mg_rank'],

                    'ag_id'                         => $result->fields['ag_id'],
                    'ag_name'                       => $result->fields['ag_name'],
                    'ag_brief'                      => $result->fields['ag_brief'],
                    'ag_privilege'                  => unserialize($result->fields['ag_privilege']),
                    'ag_fileallow'                  => unserialize($result->fields['ag_fileallow']),
                    'ag_rank'                       => $result->fields['ag_rank'],
                    'ag_if_enable'                  => $result->fields['ag_if_enable'],
                );
            }
        }
        if (empty($member_info['id'])) {
            $sys->prompt("failed","此会员不存在<!-- mid not exists -->");
        } elseif ($member_info['mg_ag_id'] > 0 && $ADMIN['ag_privilege']['admin_manage'] != "1") {
            $sys->prompt("failed","您没有权限管理管理员<!-- admin_manage not allow -->");
        } else {
            $sql = "SELECT mg_id, mg_type, mg_point_begin, mg_point_end, mg_name
                    FROM ".DB_TABLE_MEMBER_GROUP."
                    WHERE mg_type!='".$CONFIG['default_group_guest']."'
                    GROUP BY mg_type
                    ORDER BY mg_rank,mg_id";
            $result_member_group = &$db->Execute($sql);
            if (!$result_member_group) {
                echo $db->ErrorMsg();
            } else {
                while(!$result_member_group->EOF) {
                    $member_group_list[] = array(
                        "mg_id"             => $result_member_group->fields['mg_id'],
                        "mg_type"           => $result_member_group->fields['mg_type'],
                        "mg_point_begin"    => $result_member_group->fields['mg_point_begin'],
                        "mg_point_end"      => $result_member_group->fields['mg_point_end'],
                        "mg_name"           => $result_member_group->fields['mg_name'],
                    );
                    $result_member_group->MoveNext();
                }
            }

            $array_select  = array("question");
            $select_option = $sys->return_select($array_select);

            $t->assign(array(
                "member_group_list" => $member_group_list,
                "select_option"     => $select_option,
                "member_info"     => $member_info,
            ));
        }
    }

}elseif($sys->get['ope'] == "if_enable"){

    if (!preg_match("/^[0-9]+$/",$sys->get['mid'])) {
        $sys->prompt("failed","非法操作!<!-- mid error -->");
    } elseif (!preg_match("/^[123]{1}$/",$sys->get['if_enable'])) {
        $sys->prompt("failed","非法操作!<!-- if_enable error -->");
    } else {

        $sql_data = array(
            "if_enable" => $sys->get['if_enable'],
        );
        $result = func::db_update(DB_TABLE_MEMBER, $sql_data, "id='".$sys->get['mid']."'");
        if (!$result) {
            $sys->prompt("failed","非法操作!<!-- db_update failed -->");
        }

        $sys->prompt("jump",$CONFIGURE['common']['control_admin']."?act=member&pag=".$sys->get['pag']);
   }

}elseif($sys->get['ope'] == "del"){

    // check the post
    if (!preg_match("/^[0-9]+$/",$sys->get['mid'])){
        $sys->prompt("failed","非法操作!<!-- mid error -->");
    }else{

        $sql = "DELETE FROM ".DB_TABLE_MEMBER."
                WHERE id=".$sys->get['mid'];
        $result = $db->Execute($sql);
        if (!$result) {
            echo $db->ErrorMsg();
        } else {
            $sql = "DELETE FROM ".DB_TABLE_MEMBER_CONTACT."
                    WHERE mid=".$sys->get['mid'];
            $result = $db->Execute($sql);
            $sql = "DELETE FROM ".DB_TABLE_MEMBER_DETAIL."
                    WHERE mid=".$sys->get['mid'];
            $result = $db->Execute($sql);
        }

        $sys->prompt("jump",$CONFIGURE['common']['control_admin']."?act=member&pag=".$sys->get['pag']);
    }

}else{

    $where          = "";
    $where_total    = "";
    $page_url       = "";

    if (!empty($sys->get['mid'])) {
        $where          .= "AND m.id='".addslashes($sys->get['mid'])."'";
        $where_total    .= "AND id='".addslashes($sys->get['mid'])."'";
        $page_url       .= "&id=".$sys->get['mid']."";
    }
    if (!empty($sys->get['username'])) {
        $where          .= "AND m.username='".addslashes($sys->get['username'])."'";
        $where_total    .= "AND username='".addslashes($sys->get['username'])."'";
        $page_url       .= "&username=".$sys->get['username']."";
    }
    if (!empty($sys->get['email'])) {
        $where          .= "AND m.email='".addslashes($sys->get['email'])."'";
        $where_total    .= "AND email='".addslashes($sys->get['email'])."'";
        $page_url       .= "&email=".$sys->get['email']."";
    }
    if (!empty($sys->get['card'])) {
        $where          .= "AND m.card='".addslashes($sys->get['card'])."'";
        $where_total    .= "AND card='".addslashes($sys->get['card'])."'";
        $page_url       .= "&card=".$sys->get['card']."";
    }
    $where       = substr(trim($where), 0, 3) == "AND" ? substr(trim($where), 3) : trim($where);
    $where_total = substr(trim($where_total), 0, 3) == "AND" ? substr(trim($where_total), 3) : trim($where_total);
    $where       = $where != "" ? "WHERE ".$where : "";

    $total_record = func::db_count_record(DB_TABLE_MEMBER, $where_total);
    $bwpage->set_record_listnum("20");
    $bwpage->set_record($total_record);
    $bwpage->page($CONFIGURE['common']['control_admin']."?act=member".$page_url."&pag=%s");
    $sql = "SELECT m.*,mg.mg_id,mg.mg_name
            FROM ".DB_TABLE_MEMBER." m
            LEFT JOIN ".DB_TABLE_MEMBER_GROUP." mg ON mg.mg_type=m.mg_type
                AND (mg.mg_point_begin<=m.point || mg.mg_point_begin IS NULL)
                AND (mg.mg_point_end>=m.point || mg.mg_point_end IS NULL)
            ".$where."
            GROUP BY m.id
            ORDER BY m.id DESC
            LIMIT ".$bwpage->record_listfirst.",".$bwpage->record_listnum;
    $result = &$db->Execute($sql);
    if (!$result) {
        echo $db->ErrorMsg();
    } else {
        while(!$result->EOF) {
            $member_list[] = array(
                "id"                => $result->fields['id'],
                "username"          => $result->fields['username'],
                "email"             => $result->fields['email'],
                "card"              => $result->fields['card'],
                "password"          => $result->fields['password'],
                "question_type"     => $result->fields['question_type'],
                "question"          => $result->fields['question'],
                "answer"            => $result->fields['answer'],
                "mg_type"           => $result->fields['mg_type'],
                "mg_type_expired"   => $result->fields['mg_type_expired'],
                "silver"            => $result->fields['silver'],
                "point"             => $result->fields['point'],
                "bonus"             => $result->fields['bonus'],
                "pile1"             => $result->fields['pile1'],
                "pile2"             => $result->fields['pile2'],
                "pile3"             => $result->fields['pile3'],
                "pile4"             => $result->fields['pile4'],
                "pile5"             => $result->fields['pile5'],
                "pile6"             => $result->fields['pile6'],
                "active_id"         => $result->fields['active_id'],
                "if_active"         => $result->fields['if_active'],
                "if_enable"         => $result->fields['if_enable'],
                "if_email"          => $result->fields['if_email'],
                "ip_active"         => $result->fields['ip_active'],
                "ip_created"        => $result->fields['ip_created'],
                "ip_change"         => $result->fields['ip_change'],
                "ip_lastvisit"      => $result->fields['ip_lastvisit'],
                "time_active"       => $result->fields['time_active'],
                "time_created"      => $result->fields['time_created'],
                "time_change"       => $result->fields['time_change'],
                "time_lastvisit"    => $result->fields['time_lastvisit'],
                "cumulant_silver"   => $result->fields['cumulant_silver'],
                "cumulant_offer"    => $result->fields['cumulant_offer'],
                "cumulant_online"   => $result->fields['cumulant_online'],

                "mg_id"             => $result->fields['mg_id'],
                "mg_name"           => $result->fields['mg_name'],
            );
            $result->MoveNext();
        }
    }
    $t->assign(array(
        "member_list"   => $member_list,
        "pagination"    => $bwpage->pagination,
    ));
}
?>
